package com.fafa.swing.base;

import javax.swing.*;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

/**
 * @author : fafa
 * @version V1.0
 * @Project: SwingTest
 * @Package com.fafa.swing
 * @Description: JColorChooserDemo
 * @date Date : 2019年11月25日 23:15
 */
public class JColorChooserDemo {

    public JColorChooserDemo(){
        JFrame jFrame = new JFrame("颜色选择器");
        JColorChooser cc = new JColorChooser();
        cc.showDialog(jFrame, "颜色选择器", Color.white);
        cc.addPropertyChangeListener(new ColorChooserListener());
        jFrame.setVisible(true);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.setBounds(500,500,400,200);
    }

    public static void main(String[] args) {
        new JColorChooserDemo();
    }

    private class ColorChooserListener implements PropertyChangeListener{

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            System.out.println(evt.getPropertyName());
        }
    }
}
